import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

import axios from '@/utlis/axios'

export default new Vuex.Store({
  //data
  state: {
    data: '',
  },
  //computed
  getters: {
  },
  //处理同步方法
  mutations: {
    getdata(state,data) {
     state.data = data
    }
  },
  //处理异步方法
  actions: {
    async getDate(store) {
      const { data: res } = await axios.get('/grade')
      store.commit('getdata', res.data)
    }
  },
  //模块化开发  一般不得用
  modules: {
  }
})
